<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<meta http-equiv="set-cookie" contect="Mon,12 May 2001 00:20:00 GMT">
<meta http-equiv="Page-Enter" contect="revealTrans(duration=10,transtion= 50)">
<meta http-equiv="Page-Exit" contect="revealTrans(duration=20，transtion =6)">
<meta HTTP-EQUIV="pragma" contect="no-cache"> 
<meta HTTP-EQUIV="Cache-Control" contect="no-cache, must-revalidate"> 
<meta HTTP-EQUIV="expires" contect="Wed, 26 Feb 1997 08:21:57 GMT"> 

<title>润山东方百货<sitemesh:write property='title' /></title>
<c:set var="ctx" scope="session" value="${pageContext.request.contextPath}"></c:set>
<script type="text/javascript">
	var ctx = "${ctx }";
</script>

<link rel="stylesheet" href="<c:url value='/static/skins/css/web.css'/>">

<script src="<c:url value='/static/plugins/jquery/1.11.2/jquery.js'/>"></script>
<script src="<c:url value="/static/skins/js/web.js" />"></script>
<script src="<c:url value="/static/plugins/jee/DateFormat.js" />"></script>
<script src="<c:url value="/static/plugins/jee/UUID.js" />"></script>
<script src="<c:url value="/static/skins/js/web.plugins.js" />"></script>

<script type="text/javascript">
	function loadImage(id, src, callback) {
		var imgloader = new window.Image();
		//当图片成功加载到浏览器缓存
		imgloader.onload = function(evt) {
			if (typeof (imgloader.readyState) == 'undefined') {
				imgloader.readyState = 'undefined';
			}
			//在IE8以及以下版本中需要判断readyState而不是complete
			if ((imgloader.readyState == 'complete' || imgloader.readyState == "loaded") || imgloader.complete) {
				callback({
					'msg' : 'ok',
					'src' : src,
					'id' : id
				});
			} else {
				imgloader.onreadystatechange(evt);
			}
		};

		imgloader.onerror = function(evt) {
			callback({
				'msg' : 'error',
				'id' : id
			});
		};

		imgloader.onreadystatechange = function(e) {
			//此方法只有IE8以及一下版本会调用
		};
		imgloader.src = src;
	}

	var loadResult = function(data) {
		data = data || {};
		if (typeof (data.msg) != 'undefined') {
			if (data.msg == 'ok') { // 真实图片加载成功
				document.getElementById('' + data.id).src = data.src;
			} else { // 真实图片加载失败
				var loadimgPath = ctx + "/static/skins/images/unload.png";
				document.getElementById('' + data.id).src = loadimgPath;
			}
		}
	}
</script>
<sitemesh:write property='head' />
</head>

<body>
	<div class="weixin">
		<sitemesh:write property='body' />
		<input type="hidden" id="openid" name="openid" value="${openid}" />
	</div>
</body>

<script type="text/javascript">
$(function () {
	$.ajaxSetup({
		cache: false,
		async: false
	});
	
	$.each($("img[done!=true]"), function (i, n) {
		var loadimgPath = ctx + "/static/skins/images/imgloader.gif";
		var id = Math.uuid(10);
		var imgUrl = $(this).attr("src");
		$(this).attr("src", loadimgPath);
		$(this).attr("id", id);
		loadImage(id, imgUrl, loadResult);
	});
});
</script>
</html>
